package com.leyou.exception;

import com.leyou.common.pojo.ResultInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobaExceptionHander {

    private static final Logger LOGGER = LoggerFactory.getLogger(GlobaExceptionHander.class);

    @ExceptionHandler(BusinessException.class)
    public ResultInfo BusinessException(BusinessException e){
        LOGGER.info(e.getMsg(),e);
        return ResultInfo.error(e.getMsg());
    }
}
